/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.libjpa.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DecoratorPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * Main entry point.
 *
 * @author bruno
 */
public class MainEntryPoint implements EntryPoint {
    /** 
     * Creates a new instance of MainEntryPoint
     */
    public MainEntryPoint() {
    }

    /** 
     * The entry point method, called automatically by loading a module
     * that declares an implementing class as an entry-point
     */
    public void onModuleLoad() {

        //Definição do frame principal
        final Label statusLabel = new Label("Status inicial.");
        VerticalPanel vTable = new VerticalPanel();
        DecoratorPanel tablePanel = new DecoratorPanel();

        //Definição dos botões do Menu
        Button btnCadPessoa = new Button("Cadastro de Pessoas");
        Button btnCadPerfil = new Button("Cadastro de Perfis");
        Button btnCadItem = new Button("Cadastro de Pessoas");
        Button btnEmpresta = new Button("Efetuar Emprestimo");
        Button btnDevolve = new Button("Efetuar Devolucao");
        Button btnCstPessoa = new Button("Consultar Pessoas");
        Button btnCstPerfil = new Button("Consultar Perfis");
        Button btnCstItem = new Button("Consultar Itens");
        Button btnCstEmprestimo = new Button("Consultar Emprestimos");
        VerticalPanel vMenu = new VerticalPanel();
        DecoratorPanel menuPanel = new DecoratorPanel();

        // Create an asynchronous callback to handle the result.
        AsyncCallback<String> callback = new AsyncCallback<String>() {
            public void onSuccess(String result) {
                statusLabel.setText(result);
            }

            public void onFailure(Throwable caught) {
                statusLabel.setText("Falha de comunicação.");
            }
        };

        btnCadPessoa.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                ChangeTableAsync GWT.create(ChangeTable.class).getPessoas.;
            }
        });

        RootPanel.get("slot1").add(menuPanel);
        RootPanel.get("slot2").add(tablePanel);

    }

}
